#ifndef NW_PROTOCOL_H_
#define NW_PROTOCOL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "nw_client_struct.h"

enum{CMD_LEVEL_0 = 0, CMD_LEVEL_1};

enum
{
   E_NW_ALARM_DOOR = 0x01,
   E_NW_ALARM_SMOKE = 0x02,
   E_NW_ALARM_LIGHTPRO = 0x03,
   E_NW_ALARM_STOPBUTTON = 0x04,
   E_NW_ALARM_WATER = 0x05,
   E_NW_ALARM_OBLIQUE = 0x06,
   E_NW_ALARM_FANS = 0x07,
   E_NW_ALARM_MAINNDEV_FANS = 0x08,
   E_NW_ALARM_PE = 0x09,
   E_NW_ALARM_LCD_COMM = 0x0a,
   E_NW_ALARM_RFCARD = 0x0b,
   E_NW_ALARM_PRINT = 0x0c,
   E_NW_ALARM_MODULE = 0x0d,
   E_NW_ALARM_MODULE_COMM = 0x0e,
   E_NW_ALARM_INSULATION = 0x0f,
   E_NW_ALARM_ASSIANTPOWER = 0x10,
   E_NW_ALARM_FULE = 0x11,
   E_NW_ALARM_PE_BREAK = 0x12,
   E_NW_ALARM_CP_CONNECT = 0x13,
   E_NW_ALARM_SYS_LOSTPOWER = 0x14,
   E_NW_ALARM_ELEC_COMM = 0x15,
   E_NW_ALARM_ELEC_CAL = 0x16,
   E_NW_ALARM_INPIT_BREAKER = 0x17,
   E_NW_ALARM_OUTPUT_ACTION = 0x18,
   E_NW_ALARM_OUTPUTBREAKER_ADJOIN = 0x19,
   E_NW_ALARM_LOCK = 0x1a,
   E_NW_ALARM_NONE_0X1B = 0x1b,
   E_NW_ALARM_OVERTEMP = 0x1c,
   E_NW_ALARM_INTERFAVE_OVERTEMP = 0x1d,
   E_NW_ALARM_V_OVER_A = 0x1e,
   E_NW_ALARM_V_OVER_B = 0x1f,
   E_NW_ALARM_V_OVER_C = 0x20,
   E_NW_ALARM_V_LOW_A = 0x21,
   E_NW_ALARM_V_LOW_B = 0x22,
   E_NW_ALARM_V_LOW_C = 0x23,
   E_NW_ALARM_I_OVER_A = 0x24,
   E_NW_ALARM_I_OVER_B = 0x25,
   E_NW_ALARM_I_OVER_C = 0x26,
   E_NW_ALARM_DEV_PLAT_COMM = 0x27,
   E_NW_ALARM_OTHER = 0xff
};

enum
{
    E_CMD_DOWN_BLACKLIST = 1, //黑名单下发时下行数据
    E_CMD_DOWN_CHARGE_AUTH =2,  //充电鉴权下行数据
    E_CMD_DOWN_CHARGE_RECORD_CONF = 3, //充电记录确认数据
    E_CMD_DOWN_CHARGE_SETTLE = 4,//充电扣款后下行数据
    E_CMD_DOWN_RANDOM_NUM=5, //交易取随机数下行数据
    E_CMD_DOWN_COST_MODE=6, //下发计费模型下行数据
    E_CMD_DOWN_DOUBLE_AUTH_RANDOM_NUM=7, //双向认证中运营系统下发随机数下行数据
    E_CMD_DOWN_DOUBLE_AUTH_DATA=8, //双向认证中运营系统下发认证数据下行数据
    E_CMD_DOWN_ESAM_KEY=9, //ESAM密钥更新命令下行数据
    E_CMD_DOWN_ESAM_FIELD1=10, //ESAM密钥更新中密钥文件1下发下行数据
    E_CMD_DOWN_ESAM_FIELD2=11, //ESAM密钥更新中密钥文件2下发下发数据
    E_CMD_DOWN_REMOTE_START_CHARGE=12, //远程启动充电
    E_CMD_DOWN_REMOTE_STOP_CHARGE=13, //远程终止充电
    E_CMD_DOWN_REMOTE_POWER_SET=14, //远程功率设置
    E_CMD_DOWN_REMOTE_UPDATE=15, //远程升级启动
    E_CMD_DOWN_CHARGING_DATA_ACK=16, //充电过程中数据上报确认数据
    E_CMD_DOWN_DEV_PARA_SET=17, //充电设备数据上报参数设置
    E_CMD_DOWN_SM4_KEY_UPDATE=18, //SM4密钥更新
    E_CMD_DOWN_REMOTE_START_CHARGE_RET_ACK=19, //远程启动充电执行结果确认
	  E_CMD_DOWN_REMOTE_CALL_CHARGERECORD = 20,//远程召唤充电记录
	  E_CMD_DOWN_REMOTE_UPDATE_USERREMAIN = 21,//远程更新用户帐户余额
	  E_CMD_DOWN_REMOTE_CALL_DEVRTC = 22,//远程召唤充电桩时钟
  	E_CMD_DOWN_VIN_AUTHDATA = 23,//VIN鉴权下行数据
	  E_CMD_DOWN_REMOTE_CALL_DEVPARA = 24,//远程召唤设备参数
	  E_CMD_DOWN_REMOTE_SET_QRCODE = 25,//远程设置二维码
	  E_CMD_DOWN_REMOTE_CALL_DEVCOSTMODE_PARA = 26,//远程召唤充电桩计费模型参数
	  E_CMD_DOWN_REMOTE_CALL_MEDIA_FILE = 27,//远程召唤广告桩媒体文件
	  E_CMD_DOWN_PLAYCONFIG_DATA = 28,//下发播放配置方案下行数据
	  E_CMD_DOWN_REMOTE_CALL_PALYCONFIG_FILE = 29,//远程召唤广告桩播放配置方案
	  E_CMD_DOWN_REMOTE_CALL_MEDIAPLAY_TOTAL = 30,//远程召唤广告桩媒体文件播放统计
	  E_CMD_DOWN_REMOTE_ENABLE_CONTROL = 32,//远程使能控制
    E_CMD_DOWN_ALARMINFO = 33//告警/故障信息下行数据
};

enum
{
    E_CMD_UP_CHARGE_AUTH = 1,  //鉴权数据
    E_CMD_UP_CHARGE_RECORD = 2, //充电记录上传数据
    E_CMD_UP_RANDOM_NUM=3, //交易取随机数
    E_CMD_UP_COST_MODE_REQ=4, //请求下发计费模型数据
    E_CMD_UP_COST_MODE_ACK=5, //下发计费模型结果数据
    E_CMD_UP_DOUBLE_AUTH_DATA_REQ=6, //双向认证终端发起双向认证上行数据
    E_CMD_UP_DOUBLE_AUTH_DATA_UP=7, //双向认证终端上送认证上行数据
    E_CMD_UP_ESAM_KEY_NORMAL=8, //ESAM密钥更新中基本数据
    E_CMD_UP_ESAM_FIELD1_ACK=9, //ESAM密钥文件1更新成功数据
    E_CMD_UP_ESAM_FIELD2_ACK=10, //ESAM密钥文件2更新成功数据
    E_CMD_UP_BLACKLIST = 11, //黑名单下发时上行数据
    E_CMD_UP_DOUBLE_AUTH_DATA_ACK=12, //双向认证终端认证运营管理系统上行数据
    E_CMD_UP_REMOTE_START_CHARGE=13, //远程启动充电执行结果
    E_CMD_UP_REMOTE_STOP_CHARGE=14, //远程终止充电执行结果
    E_CMD_UP_REMOTE_POWER_SET=15, //远程功率控制结果
    E_CMD_UP_REMOTE_UPDATE=16, //远程升级启动命令接收结果
    E_CMD_UP_CHARGING_DATA=17, //充电过程中上传数据
    E_CMD_UP_DEV_PARA_SET_ACK=18, //充电设备上报参数设置结果
    E_CMD_UP_SM4_KEY_UPDATE_ACK=19, //SM4密钥更新结果
    E_CMD_UP_REMOTE_CALL_RECORD_ACK = 20,//远程召唤充电记录结果通知
	  E_CMD_UP_REMOTE_UPDATE_USER_REMAIN_ACK = 21,//远程更新用户帐户余额通知
    E_CMD_UP_REMOTE_CALL_DEVRTC_ACK = 22,//远程召唤充电桩时钟结果
    E_CMD_UP_VIN_AUTH_DATA = 23,//vin码鉴权数据
	  E_CMD_UP_REMOTE_CALL_DEVPARA_ACK = 24,//远程召唤设备参数结果
	  E_CMD_UP_REMOTE_SETQRCODE_ACK = 25,//远程设置二维码结果
	  E_CMD_UP_REMOTE_CALL_DEVCOSTMODERPARA_ACK= 26,//远程召唤充电桩计费模型参数结果
	  E_CMD_UP_REMOTE_CALL_MEDIAFILE_ACK = 27,//远程召唤广告桩媒体文件结果
	  E_CMD_UP_DOWNLOAD_PLAYONFIG_DATA_ACK = 28,//下发播放配置方案下行数据结果
	  E_CMD_UP_REMOTE_CALL_PALYCONFIG_ACK= 29,//远程召唤广告桩播放配置方案结果
	  E_CMD_UP_REMOTE_CALL_MEDIAPLAY_TOTAL_ACK = 30,//远程召唤广告桩媒体文件播放统计结果
	  E_CMD_UP_ROUTINE_CALL_MEDIAPALY_TOTAL = 31,//定期上报广告桩媒体文件播放统计结果
	  E_CMD_UP_REMOTE_ENABLE_CONTROL_ACK = 32,//远程使能控制结果
	  E_CMD_UP_ALARMINFO = 33,//告警/故障信息上行数据   
};
void nwpro_init(struct t_nw_promsg *msg);//协议模块初始化
void nwpro_pushrecvdata(uint8 *data,uint32 len);//接收数据
uint8 nwpro_getrecvdata(uint8 *cmdget,uint8 *dataget,uint32 *lenget);//拿取解析数据

uint16 getcot(uint8 *data,uint32 len);//获取传送原因
void pro_gettime(uint8 *data,uint8 *time);//获取时间
void pro_dealkeepliveack(void);//处理心跳包

uint8 nw_getprocmd(uint8 *data,const uint32 len,uint8 *dataget,uint32 *lenget);//获取下发数据项命令与数据
void pro_getcmd_reportparaset(uint8 *data,uint32 len,void *msg);//获取设备参数信息
void pro_getcmd_costmode(uint8 *data,uint32 len,void *msg);//处理计费模型下发
void pro_getcmd_costmodedata(uint8 *data,uint32 len,struct t_costmodemsg *msg,uint32 cnt);//获取计费模型数据
void pro_getcmd_remotestart(uint8 *data,uint32 len,struct t_down_remote_start *msg);//远程启动
void pro_getcmd_remotestop(uint8 *data,uint32 len,struct t_down_remote_stop *msg);//远程停止
void pro_getcmd_chargingrecord(uint8 *data,uint32 len,struct t_down_chargingrecord_ack *ack);//上传充电记录应答
void pro_getcmd_cardauth(uint8 *data,uint32 len,struct t_down_authdata *ack);//充电鉴权应答数据
void pro_getcmd_remoteupdate(uint8 *data,uint32 len,struct t_down_remote_updatestart *updatedata);//远程启动升级
	
void probill_proinitmsg(struct t_nw_pro_init *msg,uint8 *data,uint32 *len);//协议部分构建协议标识帧
void probill_startdtmsg(uint8 *data,uint32 *len);//构建启动运输帧
void probill_allcall(uint16 cot,uint8 *data,uint32 *len);//构建总召应答帧
void probill_acyx(uint16 cot,uint32 gunno,struct t_ac_devyx *yxdata,uint8 *data,uint32 *len);//构建遥信帧
void probill_acyc_halfword(uint16 cot,uint32 gunno,struct t_ac_devyc_halfword *ycdata,uint8 *data,uint32 *len);//构建遥测帧
void probill_acyc_morehalfword(uint16 cot,uint32 gunno,struct t_ac_devyc_morehalfword *ycdata,uint8 *data,uint32 *len);//构建遥测帧多字节
void probill_timesync_ack(uint16 cot,uint8 *time,uint8 *data,uint32 *len);//构建时间同步应答帧
void probill_devparaset_ack(const struct t_up_reportpara_set_ack *ack,uint8 *data,uint32 *len);//设备参数设置应答
void probill_costmode_req(const struct t_up_require_costmode *ack,uint8 *data,uint32 *len);//请求下发计费模型
void probill_costmode_ack(const struct t_up_costmode_ack *ack,uint8 *data,uint32 *len);//下发计费模型应答
void probill_keeplive_ack(uint8 *data,uint32 *len);//构建心跳包
void probill_chargingdata(const struct t_up_chargingdata *chargingdata,uint8 *data,uint32 *len);//上报充电桩运行数据
void probill_chargerecord(const struct t_up_chargerecord *chargerecord,uint8 *data,uint32 *len);//上报充电记录
void probill_chargeauth(const struct t_up_authdata *authdata,uint8 *data,uint32 *len);//充电鉴权
void probill_remotestart_ack(const struct t_up_remote_start_ack *ackdata,uint8 *data,uint32 *len );//启动应答
void probill_remotestop_ack(const struct t_up_remote_stop_ack *ackdata,uint8 *data,uint32 *len );//远程停止应答
void probill_remoteupdate_ack(const struct t_up_remote_updatestart_ack *ackdata,uint8 *data,uint32 *len);//远程升级应答
#ifdef __cplusplus
}
#endif

#endif
